CMAKE_MINIMUM_REQUIRED(VERSION 3.8)
PROJECT(tzserver)

set(CMAKE_CXX_STANDARD_REQUIRED 20)

SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/build/bin)
SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/build/bin)

#platform common includes
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/core/json/include)
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/core/mysql/include)

if (CMAKE_COMPILER_IS_GNUCXX)
	SET(CMAKE_PREFIX_PATH, /usr/ /usr/local)
	#use ccache if available
	find_program(CCACHE_PROGRAM ccache)
	if (CCACHE_PROGRAM)
		set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "${CCACHE_PROGRAM}")
	endif(CCACHE_PROGRAM)

	#gcc include path
	INCLUDE_DIRECTORIES(/usr/include/mysql)
	INCLUDE_DIRECTORIES(/usr/local/libcore/include)
	INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/common)
	#gcc lib path
	link_directories(/usr/lib64/mysql)
	link_directories(/usr/local/libcore/lib)
	link_directories(${RUNTIME_OUTPUT_DIRECTORY})
	
	#gcc编译选项
	add_compile_options("-std=c++20" "-fcoroutines" "-rdynamic" "$<$<CONFIG:Debug>:-O0>" "$<$<CONFIG:Release>:-O2>")
endif 


ADD_SUBDIRECTORY(common)
ADD_SUBDIRECTORY(GateServer)
ADD_SUBDIRECTORY(LogicServer)
ADD_SUBDIRECTORY(DBServer)
ADD_SUBDIRECTORY(DBServer)
if (${COMPILE_CLIENT})
ADD_SUBDIRECTORY(Client)
endif (${COMPILE_CLIENT})
